package stackandqueue;

import java.util.Stack;

public class StackDemo {

    public static void main(String[] args) {
        Stack stack = new Stack();
        //入栈
        stack.push(12);
        stack.push(18);
        stack.push(7);
        stack.push(22);
        stack.push(34);

        //当栈不为空的情况下,出栈。
        while (!stack.isEmpty()) {
            System.out.println(stack.pop()); //取栈顶元素，并且弹出。
        }
    }
}
